﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _09_param
{
    // out, ref, in 参数

    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = new int[]{ 1, 2, 3, 4, 52, 54, 6, 78, 2 };
            int max, min, sum, avg;
            getMaxMinSumAvg(nums, out max,out min,out sum,out avg); //out参数，必须在函数内给所有out参数赋值
            Console.WriteLine(max);
            Console.WriteLine(min);
            Console.WriteLine(sum);
            Console.WriteLine(avg);


            Console.ReadKey();
        }

        /// <summary>
        /// 计算一个数组的最大、最小、和、平均值值
        /// </summary>
        /// <param name="nums"></param>
        /// <returns></returns>
        public static void getMaxMinSumAvg(int[] nums, out int max, out int min, out int sum, out int avg)
        {
            int[] res = new int[4];
            Array.Sort(nums);
            max = nums[nums.Length - 1];
            min = nums[0];
            int t1 = 0;
            for (int i =0; i < nums.Length; ++i)
            {
                t1 += nums[i];
            }
            sum = t1;
            avg = sum / nums.Length;
        }



        public static void Test(int a)
        {
            a += 3;
        }
    }
}
